const express = require('express');
const ClusterService = require('./../services/cluster');
const ClusterDao = require('./../dao/cluster');

const clusterRouter = express.Router();
const clusterService = new ClusterService(new ClusterDao());

clusterRouter.get('/queryAll', (req, res, next) => {
  clusterService.queryAll(req.query).then(data => {
    res._sendData = data;
    next();
  });
});
clusterRouter.get('/query', (req, res, next) => {
  clusterService.query(req.query).then(data => {
    console.log(data);
    res._sendData = data;
    next();
  });
});

clusterRouter.post('/delete', (req, res, next) => {
  clusterService.delete(req.body).then(data => {
    res._sendData = data;
    next();
  });
});

clusterRouter.post('/expunge', (req, res, next) => {
  clusterService.expunge(req.body).then(data => {
    res._sendData = data;
    next();
  });
});

module.exports = clusterRouter;

